//
//  Edge.h
//  Min-Cut
//
//  Created by Emanuele Vespa on 3/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include <iostream>
#include <vector>
#include "Vertex.h"


class Edge {
    
    int cost;
    bool mark;
    
    Vertex v1;
    Vertex v2;
    
public:
    
    Edge() {
        
        mark = false;
        cost = 0;
                
    }
    
    void setVertices(Vertex u, Vertex v){
        
        v1 = u;
        v2 = v;
    }
    
    void setCost(int value){
        
        cost = value;
        
    }
    
    void setMark( bool flag) { mark = flag; }
    
    int getCost() const { return cost; }
    
    bool isMarked(){ return mark ; }
    
    bool operator==(Edge &e){
        
        if( (this->v1.getIndex() == e.v1.getIndex()) && (this->v2.getIndex() == e.v2.getIndex()) ) return true;
        else if ( (this->v1.getIndex() == e.v2.getIndex()) && (this->v2.getIndex() == e.v1.getIndex())) return true;
        
        return false;          
        
        
    }
    
    Vertex getSource(){ return v1; }
    Vertex getDest(){ return v2; }
     
    
    Vertex getMin(){
        
       return (v1.getIndex() < v2.getIndex()) ? v1 : v2;
        
    }
    
    Vertex getMax(){
        return v1.getIndex() > v2.getIndex() ? v1 : v2;
    }
    
    
    
    
    
    
};

class CompareEdges {
    
    
public:
    bool operator()(const Edge& e1,const Edge& e2) const{
        
        if ( e1.getCost() <= e2.getCost() ) return true;
        else return false;
        
        
    }
};
